// Copyright (c) 2024，D-Robotics.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/***************************************************************************
* COPYRIGHT NOTICE
* Copyright 2024 D-Robotics, Inc.
* All rights reserved.
***************************************************************************/
#ifndef UTILITY_SENSOR_INC_IRS2381C_SETTING_H_
#define UTILITY_SENSOR_INC_IRS2381C_SETTING_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(_array)	(sizeof(_array) / sizeof(_array[0]))
#endif

struct regval {
	uint32_t addr;
	uint32_t val;
};
#define REG_NULL 0xFFFF

// 224 x 173 x 11 = 224 x 1903
static const struct regval irs2381c_224_173_5fps_setting[] = {
	{0x9288, 0x021D},
	{0x9289, 0x0224},
	{0x928A, 0x0224},
	{0x928B, 0x021D},
	{0x928C, 0x0224},
	{0x928D, 0x021D},
	{0x928E, 0x0224},
	{0x928F, 0x021D},
	{0x9290, 0x0224},
	{0x9291, 0x021D},
	{0x9292, 0x0224},
	{0x9293, 0x0224},
	{0x9294, 0x0116},
	{0x9295, 0x0116},
	{0x9296, 0x00FA},
	{0x9297, 0x0116},
	{0x9298, 0x0116},
	{0x9299, 0x0116},
	{0x929A, 0x0116},
	{0x929B, 0x0100},
	{0x929C, 0x0080},
	{0x929D, 0x0080},
	{0x929E, 0x0080},
	{0x929F, 0x0080},
	{0x92A0, 0x0080},
	{0x92A1, 0x0080},
	{0x92A2, 0x0080},
	{0x92A3, 0x0080},
	{0x92A4, 0x0040},
	{0x92A5, 0x0040},
	{0x92A6, 0x0040},
	{0x92A7, 0x0040},
	{0x92A8, 0x0040},
	{0x92A9, 0x0040},
	{0x92AA, 0x0040},
	{0x92AB, 0x0040},
	{0x92AC, 0x0040},
	{0x92AD, 0x0040},
	{0x92AE, 0x0040},
	{0x92AF, 0x0040},
	{0x92B0, 0x0040},
	{0x92B1, 0x0040},
	{0x92B2, 0x0040},
	{0x92B3, 0x0040},
	{0x92B4, 0x0040},
	{0x92B5, 0x0040},
	{0x92B6, 0x0040},
	{0x92B7, 0x0040},
	{0x92B8, 0x0040},
	{0x92B9, 0x0040},
	{0x92BA, 0x0040},
	{0x92BB, 0x0040},
	{0x92BC, 0x0040},
	{0x92BD, 0x0040},
	{0x92BE, 0x0040},
	{0x92BF, 0x0040},
	{0x92C0, 0x0040},
	{0x92C1, 0x0040},
	{0x92C2, 0x0040},
	{0x92C3, 0x0040},
	{0x92C4, 0x4227},
	{0x92C5, 0x705B},
	{0x92C6, 0x9884},
	{0x92C7, 0xBDAB},
	{0x92C8, 0x3628},
	{0x92C9, 0x5044},
	{0x92CA, 0x685D},
	{0x92CB, 0x0074},
	{0x92CC, 0x2118},
	{0x92CD, 0x322A},
	{0x92CE, 0x4139},
	{0x92CF, 0x0048},
	{0x92D0, 0x553E},
	{0x92D1, 0x736A},
	{0x92D2, 0x7B77},
	{0x92D3, 0x007F},
	{0x92D4, 0x2F27},
	{0x92D5, 0x3F37},
	{0x92D6, 0x4F47},
	{0x92D7, 0x0057},
	{0x92D8, 0x3D2A},
	{0x92D9, 0x6350},
	{0x92DA, 0x8673},
	{0x92DB, 0x0099},
	{0x92DC, 0x3725},
	{0x92DD, 0x5A48},
	{0x92DE, 0x7D6B},
	{0x92DF, 0x9F8E},
	{0x92E0, 0xC3B1},
	{0x92E1, 0x00D5},
	{0x92E2, 0x1540},
	{0x92E3, 0x08D8},
	{0x92E4, 0x0883},
	{0x92E5, 0x0855},
	{0x92E6, 0x082A},
	{0x92E7, 0x0001},
	{0x92E8, 0x0271},
	{0x92E9, 0xFFFF},
	{0x92EA, 0xFFFF},
	{0x92EB, 0xFFFF},
	{0x92EC, 0xFFFF},
	{0x92ED, 0x0000},
	{0x92EE, 0x0000},
	{0x92EF, 0x0000},
	{0x92F0, 0x0010},
	{0xA00C, 0x0135},
	{0xA008, 0x1513},
	{0xA001, 0x0007},
	{0x9000, 0x1788},
	{0x9001, 0x0000},
	{0x9002, 0x5788},
	{0x9003, 0x0000},
	{0x9004, 0x5788},
	{0x9005, 0x0000},
	{0x9006, 0x5788},
	{0x9007, 0x0000},
	{0x9008, 0x5788},
	{0x9009, 0x0000},
	{0x900A, 0x51A6},
	{0x900B, 0x0000},
	{0x900C, 0x51A6},
	{0x900D, 0x0000},
	{0x900E, 0x51A6},
	{0x900F, 0x0000},
	{0x9010, 0x51A6},
	{0x9011, 0x0000},
	{0x9012, 0x51A6},
	{0x9013, 0x0000},
	{0x9014, 0x51A6},
	{0x9015, 0x0000},
	{0x9080, 0x1E1E},
	{0x9081, 0x0000},
	{0x9082, 0x10A0},
	{0x9083, 0x00A0},
	{0x9084, 0x8000},
	{0x9085, 0x6F10},
	{0x9086, 0x0000},
	{0x9087, 0x0000},
	{0x9088, 0x0000},
	{0x9089, 0x0000},
	{0x908A, 0x6F10},
	{0x908B, 0x0000},
	{0x908C, 0x0020},
	{0x908D, 0x0000},
	{0x908E, 0x0000},
	{0x908F, 0x6F10},
	{0x9090, 0x0000},
	{0x9091, 0x0040},
	{0x9092, 0x0000},
	{0x9093, 0x0000},
	{0x9094, 0x6F10},
	{0x9095, 0x0000},
	{0x9096, 0x0060},
	{0x9097, 0x0000},
	{0x9098, 0x8000},
	{0x9099, 0x634C},
	{0x909A, 0x0000},
	{0x909B, 0x1000},
	{0x909C, 0x0000},
	{0x909D, 0x0000},
	{0x909E, 0x634C},
	{0x909F, 0x0000},
	{0x90A0, 0x1020},
	{0x90A1, 0x0000},
	{0x90A2, 0x0000},
	{0x90A3, 0x634C},
	{0x90A4, 0x0000},
	{0x90A5, 0x1040},
	{0x90A6, 0x0000},
	{0x90A7, 0x0000},
	{0x90A8, 0x634C},
	{0x90A9, 0x0000},
	{0x90AA, 0x1060},
	{0x90AB, 0x0000},
	{0x90AC, 0x0000},
	{0x90AD, 0x634C},
	{0x90AE, 0x0000},
	{0x90AF, 0x10A0},
	{0x90B0, 0x00A0},
	{0x90B1, 0x0000},
	{0x90B2, 0x634C},
	{0x90B3, 0x0000},
	{0x90B4, 0x1000},
	{0x90B5, 0x00A0},
	{0x90B6, 0x8000},
	{0x91C0, 0x0592},
	{0x91C1, 0xDF00},
	{0x91C2, 0xAB00},
	{0x91C3, 0x0508},
	{0x91C4, 0x0008},
	{0x91C5, 0x0020},
	{0x91C6, 0x0008},
	{0x91CD, 0x0009},
	{0x91CE, 0x249F},
	{0x91CF, 0x000B},
	{0x91D3, 0x249F},
	{0x91DB, 0x0008},
	{0x91EA, 0x1EA1},
	{0x91EB, 0xBF26},
	{0x91EC, 0x0008},
	{0x91ED, 0x1101},
	{0x91EE, 0x0000},
	{0x91EF, 0x02F0},
	{0x91F0, 0x0000},
	{0x91F1, 0x0011},
	{0x91F2, 0x16A1},
	{0x91F3, 0x1EB8},
	{0x91F4, 0x0005},
	{0x91F5, 0x1001},
	{0x91F6, 0x0000},
	{0x91F7, 0x04A0},
	{0x91F8, 0x0000},
	{0x91F9, 0x0002},
	{0x9220, 0x0003},
	{0x9221, 0x000C},
	{0x9244, 0x0003},
	{0x9245, 0x0008},
	{0x9268, 0x0001},
	{0x9269, 0x0001},
	{0x92F1, 0x1EC5},
	{0x9401, 0x0002},
};

//master
static struct regval irs2381c_stream_on_setting[] = {
	{0x9400, 0x0001},	 /* stream on */
};
//master
static struct regval irs2381c_stream_off_setting[] = {
	{0x9400, 0x0000},	 /* stream off */
};

// Slave mode is not debugged, reserved
static struct regval irs2381c_slave_mode_stream_on_setting[] = {
	{0x9402, 0x0000},
	{0xA001, 0x0005},
	{0xA00A, 0x1A13},
	{0x9402, 0x0001},
};

static struct regval irs2381c_slave_mode_stream_off_setting[] = {
	{0x9402, 0x0007},
	{REG_NULL, 100},
	{0xA001, 0x0000},
	{0x8609, 0xBB5B},
	{0x9402, 0x0000},
};

#ifdef __cplusplus
}
#endif

#endif  //UTILITY_SENSOR_INC_IRS2381C_SETTING_H_
